// This file is part of OpenMeca, an easy software to do mechanical simulation.
//
// Author(s)    :  - Damien ANDRE  <openmeca@gmail.com>
//
// Copyright (C) 2012 Damien ANDRE
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.


#ifndef OpenMeca_Gui_MainWindow_hpp
#define OpenMeca_Gui_MainWindow_hpp

#include <QMainWindow>

#include "OpenMeca/ui/ui_MainWindow.h"
#include "OpenMeca/Core/GlobalSetting.hpp"
#include "OpenMeca/Gui/WidgetScale.hpp"

namespace OpenMeca
{
  namespace Gui
  {
    class Dialog;

    class MainWindow : public QMainWindow, private Ui::MainWindow
    {
      Q_OBJECT
      
      public:
      static MainWindow& Get();
      MainWindow(QWidget * parent=0);
      ~MainWindow();
      
      TreeView& GetTreeView();
      const TreeView& GetTreeView() const;

      Viewer& GetViewer();
      const Viewer& GetViewer() const;
      
      void AddGlobalSetting(Core::GlobalSetting&);
      void RemoveGlobalSetting(Core::GlobalSetting&);
      QToolBox& GetDialogContainer();
      void DialogContainerIsBusy(Dialog&);
      void DialogContainerIsFree(Dialog&);					 
      void AddToHistoric(QAction&);
      int GetIconSize();			  
					 
    private slots:
      void Undo();
      void Redo();
      void SaveAs();
      void Save();
      void Load();

    private:
      void UpdateHistoric();
      void closeEvent(QCloseEvent* event);

    private:
      static MainWindow* me_;
      Core::SetOf<Core::GlobalSetting> globalSet_;
      Dialog* currentDialog_;
      std::vector<QAction*> userActions_;
      std::string currentFileName_;
      const int iconSize_;
      WidgetScale* scalePart_;
      // QBoxLayout *dialogContainerLayout_;


      
    };

  }
}
#endif
